#!/usr/bin/perl

use Socket;

$server='127.0.0.1';
$rport=9000;
$timeout = 10;

sub internal_error {
	print stderr "internal error\n";
	while(1) {
		local $|=1;
		print "\a\a\a\a\a\a\a\a\a\a\a";
		select undef, undef, undef, 0.25;
	}
}

sub alarma {
	print stderr "server down $server:$rport\n";
	while(1) {
		local $|=1;
		print "\a\a\a\a\a\a\a\a\a\a\a";
		select undef, undef, undef, 0.25;
	}
}

while(1) {
	socket SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') or internal_error();
	connect SOCK, sockaddr_in($rport, inet_aton($server)) or alarma();
	shutdown SOCK, 2;
	sleep $timeout;
}



